import type {
  RoleAddParamsI,
  RoleDetailI,
  RoleI,
  RolePermissionTreeI,
  RoleUserListI,
  RoleUserListParamsI,
} from '@/types/system.d.ts'
import { http } from '@/utils/reuqest'

/**
 * 查询所有角色
 */
export const roleGetRoleListApi = () => {
  return http.get<RoleI[]>('park/sys/role')
}
/**
 * 查询所有功能权限
 */
export const roleGetPermissionTreeApi = () => {
  return http.get<RolePermissionTreeI[]>('park/sys/permision/all/tree')
}
/**
 * 查询角色详情
 */
export const roleGetRoleDetailApi = (roleId: number) => {
  return http.get<RoleDetailI>(`park/sys/role/${roleId}`)
}
/**
 * 查询角色关联的用户数据
 */
export const roleGetRoleUserDataApi = (
  roleId: number,
  params: RoleUserListParamsI,
) => {
  return http.get<RoleUserListI>(`park/sys/roleUser/${roleId}`, params)
}
/**
 * 添加角色
 */
export const roleAddRoleApi = (data: RoleAddParamsI) => {
  return http.post('park/sys/role', data)
}
/**
 * 修改角色
 */
export const roleEditRoleApi = (data: RoleAddParamsI) => {
  return http.put('park/sys/role', data)
}
/**
 * 删除角色
 */
export const roleDelRoleApi = (id: number) => {
  return http.delete<null>(`park/sys/role/${id}`)
}
